const qs = require('qs');
export function partyclass(){
    return fetch('/dts/data/partyclass.json').then((response) => response.json())
}
export function getwenankuData(data){
    var str = "?" + qs.stringify(data)
    return fetch(`/dts/titashuo/getlist.html${str}`, {
        method: 'get',
    }).then((response) => response.json())
}
/**
 * 删除文案
 * @param {*} tiddata 
 * @returns 
 */
export function delwenankuData(tiddata){
    var requestOptions = {
        method: 'POST',
        body: tiddata,
        redirect: 'follow'
      };
    return fetch("/dts/titashuo/deleteinfo.html", requestOptions)
    .then((response) => response)
}
/**
 * 获取收藏文案
 * @param {*} data 
 * @returns 
 */
export function getShoucangData(data){
    var requestOptions = {
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        body: data,
        redirect: 'follow'
    };
    return fetch('/dts/titashuo/getfavlist.html', requestOptions)
    .then((response) => response.json())
}
/**
 * 添加文案
 * @param {*} data 
 * @returns 
 */
export function addwenankuData(data){
    var requestOptions = {
        method: 'POST',
        body: data,
        redirect: 'follow'
        };
    return fetch("/dts/titashuo/updateinfo.html", requestOptions).then((response) => response)

}
/**
 * 收藏
 */
export function shouChang(data){
    var urlencoded = new URLSearchParams();
    urlencoded.append("data", JSON.stringify(data));
    var myHeaders = new Headers();
    myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
    var requestOptions = {
        method: 'POST',
        headers: myHeaders,
        body: urlencoded,
        redirect: 'follow'
        };
    
    return fetch("/dts/titashuo/favtitashuo.html", requestOptions)
    .then(response => response.text())
    
}
/**
 * 使用量+1
 */
export function usetitashuo(data){
    var urlencoded = new URLSearchParams();
    urlencoded.append("data", JSON.stringify(data));
    var myHeaders = new Headers();
    myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
    var requestOptions = {
        method: 'POST',
        headers: myHeaders,
        body: urlencoded,
        redirect: 'follow'
        };
    
    return fetch("/dts/titashuo/usetitashuo.html", requestOptions)
    .then(response => response.text())
}